import { useModel } from "umi";

import AddStore from "../components/store/Add";
import EditStore from "../components/store/Edit";

const useHelperStore = () => {
    const { setModalVisible, setModalTitle, setModalWidth, setModalComponent, setModalStyle } = useModel("global.modal");

    const openAddStoreModal = ({ oiType, reloadData }) => {
        setModalTitle("添加门店信息");
        setModalVisible(true);
        setModalWidth(650);
        setModalStyle({ top: 50 });
        setModalComponent(<AddStore oiType={oiType} reloadData={reloadData} />);
    };

    const openEditStoreModal = ({ oiType, record, reloadData }) => {
        setModalTitle("编辑门店信息");
        setModalVisible(true);
        setModalWidth(650);
        setModalStyle({ top: 50 });
        setModalComponent(<EditStore oiType={oiType} store={record} reloadData={reloadData} />);
    };

    return { openAddStoreModal, openEditStoreModal };
};

export default useHelperStore;
